﻿using System;
using Caliburn.Micro;
using JY.Wpf.Core.Events;
using JY.Wpf.Core.Models;
using JY.Wpf.Core.ViewModelBases;
using JY.Wpf.Test.Views.MVVMDemoViews;
using SD.IOC.Core.Mediators;

namespace JY.Wpf.Test.ViewModels.MVVMDemoViewModels
{
    public class LicenseViewModel : ViewModelBase
    {
        #region # 变量

        #endregion

        #region # 构造器
        /// <summary>
        /// 构造器
        /// </summary>
        public LicenseViewModel()
        {
        }
        #endregion

        #region # 属性

        #endregion

        #region # Command方法
        #region # 授权——void License()
        /// <summary>
        /// 授权
        /// </summary>
        public void License()
        {
            this.EventAggregator.PublishOnUIThread(new LicenseChangedEvent(new License(DateTime.Today.AddYears(2), DateTime.Today.AddYears(2))));
        }
        #endregion
        #region # 服务授权临期——void ServiceAboutToExpire()
        /// <summary>
        /// 服务授权临期
        /// </summary>
        public void ServiceAboutToExpire()
        {
            this.EventAggregator.PublishOnUIThread(new LicenseChangedEvent(new License(DateTime.Today.AddYears(2),DateTime.Today.AddDays(14))));
        }
        #endregion
        #region # 服务授权到期——void ServiceExpire()
        /// <summary>
        /// 服务授权到期
        /// </summary>
        public void ServiceExpire()
        {
            this.EventAggregator.PublishOnUIThread(new LicenseChangedEvent(new License(DateTime.Today.AddYears(2), DateTime.Today.AddDays(-1))));
        }
        #endregion
        #region # 授权使用临期——void LicenseAboutToExpire()
        /// <summary>
        /// 授权使用临期
        /// </summary>
        public void LicenseAboutToExpire()
        {
            this.EventAggregator.PublishOnUIThread(new LicenseChangedEvent(new License(DateTime.Today.AddDays(14), DateTime.Today.AddDays(14))));
        }
        #endregion
        #region # 授权使用到期——void LicenseExpire()
        /// <summary>
        /// 授权使用到期
        /// </summary>
        public void LicenseExpire()
        {
            this.EventAggregator.PublishOnUIThread(new LicenseChangedEvent(new License(DateTime.Today.AddDays(-1), DateTime.Today.AddDays(-1))));
        }
        #endregion
        #endregion

        #region # 方法

        #endregion

        #region # 获取页面 —— object GetView(object context = null)
        /// <summary>
        /// 获取页面
        /// </summary>
        /// <param name="context">页面</param>
        /// <returns></returns>
        public override object GetView(object context = null)
        {
            return ResolveMediator.Resolve<LicenseView>();
        }
        #endregion
    }
}
